pyDHM: A Python library for applications in digital holographic microscopy

pyDHM is an open-source Python library aimed at Digital Holographic Microscopy (DHM) applications. The pyDHM is a user-friendly library written in the robust programming language of Python that provides a set of numerical processing algorithms for reconstructing amplitude and phase images for a broad range of optical DHM configurations. The pyDHM implements phase-shifting approaches for in-line and slightly off-axis systems and enables phase compensation for telecentric and non-telecentric systems. In addition, pyDHM includes three propagation algorithms for numerical focusing complex amplitude distributions in DHM and digital holography (DH) setups. We have validated the library using numerical and experimental holograms.

libraries installed. In particular, error messages are displayed if the OpenCV (cv2) and scipy libraries are not installed. An error message is displayed when users incorrectly use one of the functions based on the given holograms. In other words, we have implemented a local function, named regime, within the in-line PS techniques (e.g., PS3, PS4, and PS5) and the telecentric-based phase compensation methods (e.g., FRS, ERS, and CFS). The regime function checks the optical configuration of the DHM system (e.g., on/slight off axis versus off axis) based on the spectrum of the input hologram and determines if the called function is suitable for the given hologram. For example, let us assume that the three terms in the hologram's spectrum overlap (e.g., non off-axis configuration) and the user calls the ERS function. Since that function is only valid for holograms recorded in off-axis configuration, an error message (e.g., 'ERS equires an offaxis hologram') is displayed. We have also implemented error messages when incorrect values of s and step parameters are used for the SORS, FRS, and ERS functions. Finally, we have included a new option into the CNT function (e.g., the phase compensation function for non-telecentric holograms). This option allows the user to decide how to perform the spatial filtering of the object frequencies from the hologram spectrum (please refer to the following response). An error message will appear if the user tries to call the CNT function using the x1, x2, y1, y2 parameters with the new option 'sfmr'. Also, another error message will appear if the user cakks the CNT function using the 'sfr' option without inserting the x1, x2, y1, y2 parameters. This information can be found in the GitHub documentation.
The following text has been added to the Conclusions section in the revised manuscript: "The pyDHM library is posted publicly on GitHub (65, 66). The GitHub repository includes a complete documentation of the functions implemented, sample codes, and troubleshooting guidelines for correctly using the library. To increase the applicability of this library in our community, the GitHub repository also includes simulated and experimental holograms and some instructional videos on how to install and use the library (67-70)." Comment #5: "It is understandable that the pyDHM library serves as the first toolbox library that supports multimodality DHM numerical processing. However, its useability is poor at current stage. Immediate future work should be aiming to improve the useability with for example, a graphical user interface. There is no doubt that the spatial filtering process of the +/-1 orders in the FT of an off-axis hologram can be greatly simplified if performed in a graphical way." Response: We respectfully disagree with the reviewer regarding the useability of the current/revised library since the pyDHM library is not aimed at biology/medicine users. We believe the immediate users of the library are coders with a background in Physics and computational sciences. Nonetheless, we understand the reviewer's point of view and agree that future work should also be focused on implementing a graphical user interface (GUI) for non-coder users. For this reason, the GUI is currently under development by undergraduate students from Physics Engineering and Computational Engineering. We plan to test the usability of the GUI with our biological collaborators.
The following text has been added to the revised manuscript in the Conclusions section: "Because of the broad applicability of DHM systems in biology and medicine, we will create a graphical user interface (GUI) for the pyDHM library, aiming that users who lack coding skills and background in Optics and DHM could adopt this library." Regarding the comment about the spatial filtering process from the hologram spectrum implemented in the original library, we agree with the reviewer that some type of graphical interface can facilitate this task. For this reason, we have implemented additional functionalities to simplify the user's usability. For the rectangular and circular spatial filtering functions ('sfr' and 'sfc' defined in the utility package, Table 1), we have allow the display of the resulting filtered object spectrum from the hologram's spectrum so that users can verify that all object frequencies have been correctly cropped. On the other hand, a new function for manual spatially filtering has been added to the library (see sfmr in Table 1). This function filter the Fourier transform of a hologram using a user-defined rectangular mask. The required parameters are the hologram (field) and the Boolean parameter (display) that allows the display of the filtered hologram spectrum when it is true. It is important to mention that this function works only if the OpenCV library is installed. Finally, we have added a new option into the CNT function (e.g., the phase compensation function for nontelecentric holograms). This option allows the user to decide whether he/she manually inserts the pixel coordinates for the rectangular mask to spatially filter the object frequencies from the hologram spectrum, or manually selects the object frequencies using a popup window. The latter option is done by calling the function with the parameter spatialFilter == 'sfmr'.
The following description has been added in Table 1 of the revised manuscript:

Circular filter
sfc(field, radius, centX, centY, display) Function to filter the Fourier Transform of a hologram using a circular mask. The required parameters are: field the hologram, radius is the radius of the circular mask in pixels, and (centX, centY) are the central pixel positions for the circular mask. The Boolean parameter display shows the filtered object frequencies from the hologram spectrum when its value is true.

Rectangular filter
sfr(field, x1, x2, y1, y2, display) Function to filter the Fourier Transform of a hologram using a rectangular mask. The required parameters are: field the hologram; (x1, y1) the pixel coordinates of the upper left corner for the rectangular mask; and (x2, y2) the pixel coordinates of the lower right corner for the rectangular mask. The Boolean parameter display shows the filtered object frequencies from the hologram spectrum when its value is true.

Manual rectangular filter
sfmr(field, display) Function to filter the Fourier Transform of a hologram using a user-defined rectangular mask from a popup window. The required parameters are the hologram (field) and the Boolean parameter (display) that allows the display of the filtered hologram spectrum when it is true. It is important to mention that this function works only if the OpenCV library is installed.
The following description has been added in Table 3 of the revised manuscript: Compensation notelecentric regime CNT(inp, wavelength, dx, dy, x1, x2, y1, y2, spatialFilter): Function to reconstruct fully-compensated phase images of holograms recorded in non-telecentric regime. The function requires up to nine parameters: inp, wavelength, dx, dy, x1, x2, y1, y2. The units of wavelength, dx, dy should be microns. The DHM system should operate in off-axis configuration and nontelecentric regime. The parameter spatialFilter allows to decide how to select the object frequencies from the hologram spectrum. Use spatialFilter = 'sfmr' for a manual filter via a popup windown or spatialFilter = 'sfr' for a rectangular mask filter defined by the x1, x2, y1, y2 parameters. Users selecting the sfmr option should not insert any parameter for x1, x2, y1, and y2. In other words, the notation of the function is CNT(inp, wavelength, dx, dy, x1, x2, y1, y2, spatialFilter ='sfr') or CNT(inp, wavelength, dx, dy, spatialFilter = 'sfmr'). This function is based on the proposed method by Kemper et al. (59). We have